package be.bejug.scrumadmin.spring;

import be.bejug.scrumadmin.ScrumAdminApplication;

/**
 * The application holder class.
 * 
 * @author Glenn Dejaeger
 * 
 */
public class ApplicationHolder {

	/**
	 * Threadlocal variable.
	 */
	private static ThreadLocal<BaseApplication> app = new ThreadLocal<BaseApplication>();

	/**
	 * Sets the application.
	 * 
	 * @param application
	 *            the application
	 */
	public static void setApplication(final BaseApplication application) {
		app.set(application);
	}

	/**
	 * Resets the application.
	 */
	public static void resetApplication() {
		app.remove();
	}

	/**
	 * Gets the application.
	 * 
	 * @return the application
	 */
	public static BaseApplication getApplication() {
		return app.get();
	}

	public static String getMessage(final String key, final String... args) {
		return ((ScrumAdminApplication) getApplication())
				.getApplicationObjectSupport().getMessage(key, args);
	}
}
